package com.ssy.lingxi.order.controller.platform;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.dto.OrderMemberQueryDTO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderProcessIdVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderProcessUpdateStatusVO;
import com.ssy.lingxi.order.model.vo.platform.request.PlatformProcessMemberPageVO;
import com.ssy.lingxi.order.model.vo.platform.request.PlatformProcessUpdateVO;
import com.ssy.lingxi.order.model.vo.platform.request.PlatformProcessVO;
import com.ssy.lingxi.order.model.vo.platform.request.PlatfromProcessPageVO;
import com.ssy.lingxi.order.model.vo.platform.response.PlatformBaseTradeProcessVO;
import com.ssy.lingxi.order.model.vo.platform.response.PlatformProcessDetailVO;
import com.ssy.lingxi.order.model.vo.platform.response.PlatformProcessPageQueryVO;
import com.ssy.lingxi.order.service.platform.IPlatformTradeProcessService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 平台后台 - 交易规则配置相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/order/platform/trade/process")
public class PlatformTradeProcessController {
    @Resource
    private IPlatformTradeProcessService platformTradeProcessService;

    /**
     * 分页查询交易流程规则配置
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<PlatformProcessPageQueryVO>> pageTradeProcess(@RequestHeader HttpHeaders headers, @Valid PlatfromProcessPageVO pageVO) {
        return platformTradeProcessService.pageTradeProcess(headers, pageVO);
    }

    /**
     * 新增交易规则页面 - 查询基础交易流程列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/base/list", method = RequestMethod.GET)
    public Wrapper<List<PlatformBaseTradeProcessVO>> listBaseTradeProcess(@RequestHeader HttpHeaders headers) {
        return platformTradeProcessService.listBaseTradeProcess(headers);
    }

    /**
     * 新增交易流程规则
     * @param headers HttpHeaders信息
     * @param processVO 接口参数
     * @return 新增结果
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Wrapper<Void> createTradeProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformProcessVO processVO) {
        return platformTradeProcessService.createTradeProcess(headers, processVO);
    }

    /**
     * 查询交易流程规则详情
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<PlatformProcessDetailVO> getTradeProcess(@RequestHeader HttpHeaders headers, @Valid OrderProcessIdVO idVO) {
        return platformTradeProcessService.getTradeProcess(headers, idVO);
    }

    /**
     * 分页查询交易流程规则适用会员列表
     * @param headers HttpHeaders信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/member/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderMemberQueryDTO>> pageTradeProcessMembers(@RequestHeader HttpHeaders headers, @Valid PlatformProcessMemberPageVO pageVO) {
        return platformTradeProcessService.pageTradeProcessMembers(headers, pageVO);
    }

    /**
     * 修改交易流程规则
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updateTradeProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformProcessUpdateVO updateVO) {
        return platformTradeProcessService.updateTradeProcess(headers, updateVO);
    }

    /**
     * 修改交易流程规则状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/status/update", method = RequestMethod.POST)
    public Wrapper<Void> updateTradeProcessStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProcessUpdateStatusVO statusVO) {
        return platformTradeProcessService.updateTradeProcessStatus(headers, statusVO);
    }

    /**
     * 删除交易流程规则
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteTradeProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProcessIdVO idVO) {
        return platformTradeProcessService.deleteTradeProcess(headers, idVO);
    }
}
